package com.bwie.commodity.service.impl;

import java.util.List;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.bwie.commodity.domain.dto.CommodityBrandDTO;
import com.bwie.commodity.domain.po.CommodityBrandPO;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.bwie.commodity.mapper.CommodityBrandMapper;
import com.bwie.commodity.domain.CommodityBrand;
import com.bwie.commodity.service.ICommodityBrandService;

/**
 * 品牌管理Service业务层处理
 *
 * @author ruoyi
 * @date 2024-11-13
 */
@Service
public class CommodityBrandServiceImpl extends ServiceImpl<CommodityBrandMapper, CommodityBrandPO> implements ICommodityBrandService
{
    @Autowired
    private CommodityBrandMapper commodityBrandMapper;

    /**
     * 查询品牌管理
     *
     * @param id 品牌管理主键
     * @return 品牌管理
     */
    @Override
    public CommodityBrand selectCommodityBrandById(Long id)
    {
        return commodityBrandMapper.selectCommodityBrandById(id);
    }

    /**
     * 查询品牌管理列表
     *
     * @param commodityBrand 品牌管理
     * @return 品牌管理
     */
    @Override
    public List<CommodityBrand> selectCommodityBrandList(CommodityBrand commodityBrand)
    {
        return commodityBrandMapper.selectCommodityBrandList(commodityBrand);
    }

    /**
     * 新增或修改品牌管理
     *
     * @param commodityBrandDTO 品牌管理
     * @return 结果
     */
    @Override
    public void updateOrInsertCommodityBrand(CommodityBrandDTO commodityBrandDTO)
    {
        CommodityBrandPO commodityBrandPO = new CommodityBrandPO();
        BeanUtils.copyProperties(commodityBrandDTO, commodityBrandPO);
//        commodityBrandMapper.updateById(commodityBrandPO);
        this.saveOrUpdate(commodityBrandPO);
    }

    /**
     * 批量删除品牌管理
     *
     * @param ids 需要删除的品牌管理主键
     * @return 结果
     */
    @Override
    public int deleteCommodityBrandByIds(Long[] ids)
    {
        return commodityBrandMapper.deleteCommodityBrandByIds(ids);
    }

    /**
     * 删除品牌管理信息
     *
     * @param id 品牌管理主键
     * @return 结果
     */
    @Override
    public int deleteCommodityBrandById(Long id)
    {
        return commodityBrandMapper.deleteCommodityBrandById(id);
    }

    @Override
    public void test2() {
        System.out.println("开始执行任务二");
        long l1 = System.currentTimeMillis();
        try {
            Thread.sleep(2000);
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }
        long l2 = System.currentTimeMillis();
        System.out.println("任务二用时"+(l2-l1));
//        return new AsyncResult<String>("任务二完成");
    }

    @Override
    public void test1() {
        System.out.println("开始执行任务一");
        long l1 = System.currentTimeMillis();
        try {
            Thread.sleep(1000);
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }
        long l2 = System.currentTimeMillis();
        System.out.println("任务一用时"+(l2-l1));
//        return new AsyncResult<String>("任务一完成");
    }

    @Override
    public void test3() {
        System.out.println("开始执行任务三");
        long l1 = System.currentTimeMillis();
        try {
            Thread.sleep(3000);
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }
        long l2 = System.currentTimeMillis();
        System.out.println("任务三用时"+(l2-l1));
//        return new AsyncResult<String>("任务三完成");
    }


}
